import { create } from 'zustand'
import { immer } from 'zustand/middleware/immer'

interface User {
    obj: {
        name: string
        age: number
    }
}

type Actions = {
    updateObj: () => void
}

export const useUserStore = create<User & Actions>()(
    immer((set) => ({
        obj: {
            name: '张三',
            age: 18
        },
        updateObj: () => set((state) => {
            state.obj.age = 20
            state.obj.name = '李四'
        })
    }))
)